package f.f0.f;

import f.d;
import f.d0;
import f.f0.g.c;
import f.m;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.Socket;
import java.util.Objects;

/* compiled from: StreamAllocation */
public final class g {
    public final f.a a;
    public f.f0.f.f.a b;
    public d0 c;
    public final f.g d;
    public final d e;
    public final m f;
    public final Object g;
    public final f h;
    public int i;
    public c j;
    public boolean k;
    public boolean l;
    public boolean m;
    public c n;

    /* compiled from: StreamAllocation */
    public static final class a extends WeakReference<g> {
        public final Object a;

        public a(g gVar, Object obj) {
            super(gVar);
            this.a = obj;
        }
    }

    public g(f.g gVar, f.a aVar, d dVar, m mVar, Object obj) {
        this.d = gVar;
        this.a = aVar;
        this.e = dVar;
        this.f = mVar;
        Objects.requireNonNull((f.v.a) f.f0.a.a);
        this.h = new f(aVar, gVar.e, dVar, mVar);
        this.g = obj;
    }

    public void a(c cVar, boolean z) {
        if (this.j == null) {
            this.j = cVar;
            this.k = z;
            cVar.n.add(new a(this, this.g));
            return;
        }
        throw new IllegalStateException();
    }

    public synchronized c b() {
        return this.j;
    }

    public final Socket c(boolean z, boolean z2, boolean z3) {
        if (z3) {
            this.n = null;
        }
        z3 = true;
        if (z2) {
            this.l = true;
        }
        c cVar = this.j;
        if (cVar == null) {
            return null;
        }
        if (z) {
            cVar.k = true;
        }
        if (this.n != null) {
            return null;
        }
        if (!this.l && !cVar.k) {
            return null;
        }
        int size = cVar.n.size();
        for (int i = 0; i < size; i++) {
            if (((Reference) cVar.n.get(i)).get() == this) {
                Socket socket;
                cVar.n.remove(i);
                if (this.j.n.isEmpty()) {
                    this.j.o = System.nanoTime();
                    f.f0.a aVar = f.f0.a.a;
                    f.g gVar = this.d;
                    c cVar2 = this.j;
                    Objects.requireNonNull((f.v.a) aVar);
                    Objects.requireNonNull(gVar);
                    if (cVar2.k || gVar.a == 0) {
                        gVar.d.remove(cVar2);
                    } else {
                        gVar.notifyAll();
                        z3 = false;
                    }
                    if (z3) {
                        socket = this.j.e;
                        this.j = null;
                        return socket;
                    }
                }
                socket = null;
                this.j = null;
                return socket;
            }
        }
        throw new IllegalStateException();
    }

    /* JADX WARNING: Removed duplicated region for block: B:104:0x01ee A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:126:0x025b  */
    /* JADX WARNING: Removed duplicated region for block: B:124:0x0255  */
    public final f.f0.f.c d(int r18, int r19, int r20, int r21, boolean r22) throws java.io.IOException {
        /*
        r17 = this;
        r1 = r17;
        r2 = r1.d;
        monitor-enter(r2);
        r0 = r1.l;	 Catch:{ all -> 0x02e3 }
        if (r0 != 0) goto L_0x02db;
    L_0x0009:
        r0 = r1.n;	 Catch:{ all -> 0x02e3 }
        if (r0 != 0) goto L_0x02d3;
    L_0x000d:
        r0 = r1.m;	 Catch:{ all -> 0x02e3 }
        if (r0 != 0) goto L_0x02cb;
    L_0x0011:
        r0 = r1.j;	 Catch:{ all -> 0x02e3 }
        r3 = 0;
        r4 = 0;
        r5 = 1;
        if (r0 == 0) goto L_0x0021;
    L_0x0018:
        r6 = r0.k;	 Catch:{ all -> 0x02e3 }
        if (r6 == 0) goto L_0x0021;
    L_0x001c:
        r6 = r1.c(r4, r4, r5);	 Catch:{ all -> 0x02e3 }
        goto L_0x0022;
    L_0x0021:
        r6 = r3;
    L_0x0022:
        r7 = r1.j;	 Catch:{ all -> 0x02e3 }
        if (r7 == 0) goto L_0x0028;
    L_0x0026:
        r0 = r3;
        goto L_0x0029;
    L_0x0028:
        r7 = r3;
    L_0x0029:
        r8 = r1.k;	 Catch:{ all -> 0x02e3 }
        if (r8 != 0) goto L_0x002e;
    L_0x002d:
        r0 = r3;
    L_0x002e:
        if (r7 != 0) goto L_0x0041;
    L_0x0030:
        r8 = f.f0.a.a;	 Catch:{ all -> 0x02e3 }
        r9 = r1.d;	 Catch:{ all -> 0x02e3 }
        r10 = r1.a;	 Catch:{ all -> 0x02e3 }
        r8.c(r9, r10, r1, r3);	 Catch:{ all -> 0x02e3 }
        r8 = r1.j;	 Catch:{ all -> 0x02e3 }
        if (r8 == 0) goto L_0x003f;
    L_0x003d:
        r7 = 1;
        goto L_0x0044;
    L_0x003f:
        r3 = r1.c;	 Catch:{ all -> 0x02e3 }
    L_0x0041:
        r8 = 0;
        r8 = r7;
        r7 = 0;
    L_0x0044:
        monitor-exit(r2);	 Catch:{ all -> 0x02e3 }
        f.f0.c.g(r6);
        if (r0 == 0) goto L_0x004f;
    L_0x004a:
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
    L_0x004f:
        if (r7 == 0) goto L_0x0056;
    L_0x0051:
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
    L_0x0056:
        if (r8 == 0) goto L_0x0059;
    L_0x0058:
        return r8;
    L_0x0059:
        if (r3 != 0) goto L_0x01ea;
    L_0x005b:
        r0 = r1.b;
        if (r0 == 0) goto L_0x0065;
    L_0x005f:
        r0 = r0.a();
        if (r0 != 0) goto L_0x01ea;
    L_0x0065:
        r0 = r1.h;
        r2 = r0.b();
        if (r2 == 0) goto L_0x01e4;
    L_0x006d:
        r2 = new java.util.ArrayList;
        r2.<init>();
    L_0x0072:
        r6 = r0.c();
        if (r6 == 0) goto L_0x01cb;
    L_0x0078:
        r6 = r0.c();
        r9 = "No route to ";
        if (r6 == 0) goto L_0x01aa;
    L_0x0080:
        r6 = r0.e;
        r10 = r0.f;
        r11 = r10 + 1;
        r0.f = r11;
        r6 = r6.get(r10);
        r6 = (java.net.Proxy) r6;
        r10 = new java.util.ArrayList;
        r10.<init>();
        r0.g = r10;
        r10 = r6.type();
        r11 = java.net.Proxy.Type.DIRECT;
        if (r10 == r11) goto L_0x00db;
    L_0x009d:
        r10 = r6.type();
        r11 = java.net.Proxy.Type.SOCKS;
        if (r10 != r11) goto L_0x00a6;
    L_0x00a5:
        goto L_0x00db;
    L_0x00a6:
        r10 = r6.address();
        r11 = r10 instanceof java.net.InetSocketAddress;
        if (r11 == 0) goto L_0x00c4;
    L_0x00ae:
        r10 = (java.net.InetSocketAddress) r10;
        r11 = r10.getAddress();
        if (r11 != 0) goto L_0x00bb;
    L_0x00b6:
        r11 = r10.getHostName();
        goto L_0x00bf;
    L_0x00bb:
        r11 = r11.getHostAddress();
    L_0x00bf:
        r10 = r10.getPort();
        goto L_0x00e3;
    L_0x00c4:
        r0 = new java.lang.IllegalArgumentException;
        r2 = "Proxy.address() is not an InetSocketAddress: ";
        r2 = c.b.a.a.a.g(r2);
        r3 = r10.getClass();
        r2.append(r3);
        r2 = r2.toString();
        r0.<init>(r2);
        throw r0;
    L_0x00db:
        r10 = r0.a;
        r10 = r10.a;
        r11 = r10.d;
        r10 = r10.e;
    L_0x00e3:
        if (r10 < r5) goto L_0x0188;
    L_0x00e5:
        r12 = 65535; // 0xffff float:9.1834E-41 double:3.23786E-319;
        if (r10 > r12) goto L_0x0188;
    L_0x00ea:
        r9 = r6.type();
        r12 = java.net.Proxy.Type.SOCKS;
        if (r9 != r12) goto L_0x00fc;
    L_0x00f2:
        r9 = r0.g;
        r10 = java.net.InetSocketAddress.createUnresolved(r11, r10);
        r9.add(r10);
        goto L_0x0130;
    L_0x00fc:
        r9 = r0.d;
        java.util.Objects.requireNonNull(r9);
        r9 = r0.a;
        r9 = r9.b;
        r9 = (f.l.a) r9;
        r9 = r9.a(r11);
        r12 = r9.isEmpty();
        if (r12 != 0) goto L_0x016a;
    L_0x0111:
        r11 = r0.d;
        java.util.Objects.requireNonNull(r11);
        r11 = r9.size();
        r12 = 0;
    L_0x011b:
        if (r12 >= r11) goto L_0x0130;
    L_0x011d:
        r13 = r9.get(r12);
        r13 = (java.net.InetAddress) r13;
        r14 = r0.g;
        r15 = new java.net.InetSocketAddress;
        r15.<init>(r13, r10);
        r14.add(r15);
        r12 = r12 + 1;
        goto L_0x011b;
    L_0x0130:
        r9 = r0.g;
        r9 = r9.size();
        r10 = 0;
    L_0x0137:
        if (r10 >= r9) goto L_0x0163;
    L_0x0139:
        r11 = new f.d0;
        r12 = r0.a;
        r13 = r0.g;
        r13 = r13.get(r10);
        r13 = (java.net.InetSocketAddress) r13;
        r11.m4713init(r12, r6, r13);
        r12 = r0.b;
        monitor-enter(r12);
        r13 = r12.a;	 Catch:{ all -> 0x0160 }
        r13 = r13.contains(r11);	 Catch:{ all -> 0x0160 }
        monitor-exit(r12);
        if (r13 == 0) goto L_0x015a;
    L_0x0154:
        r12 = r0.h;
        r12.add(r11);
        goto L_0x015d;
    L_0x015a:
        r2.add(r11);
    L_0x015d:
        r10 = r10 + 1;
        goto L_0x0137;
    L_0x0160:
        r0 = move-exception;
        monitor-exit(r12);
        throw r0;
    L_0x0163:
        r6 = r2.isEmpty();
        if (r6 != 0) goto L_0x0072;
    L_0x0169:
        goto L_0x01cb;
    L_0x016a:
        r2 = new java.net.UnknownHostException;
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r0 = r0.a;
        r0 = r0.b;
        r3.append(r0);
        r0 = " returned no addresses for ";
        r3.append(r0);
        r3.append(r11);
        r0 = r3.toString();
        r2.<init>(r0);
        throw r2;
    L_0x0188:
        r0 = new java.net.SocketException;
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r2.append(r9);
        r2.append(r11);
        r3 = ":";
        r2.append(r3);
        r2.append(r10);
        r3 = "; port is out of range";
        r2.append(r3);
        r2 = r2.toString();
        r0.<init>(r2);
        throw r0;
    L_0x01aa:
        r2 = new java.net.SocketException;
        r3 = c.b.a.a.a.g(r9);
        r4 = r0.a;
        r4 = r4.a;
        r4 = r4.d;
        r3.append(r4);
        r4 = "; exhausted proxy configurations: ";
        r3.append(r4);
        r0 = r0.e;
        r3.append(r0);
        r0 = r3.toString();
        r2.<init>(r0);
        throw r2;
    L_0x01cb:
        r6 = r2.isEmpty();
        if (r6 == 0) goto L_0x01db;
    L_0x01d1:
        r6 = r0.h;
        r2.addAll(r6);
        r0 = r0.h;
        r0.clear();
    L_0x01db:
        r0 = new f.f0.f.f$a;
        r0.m4728init(r2);
        r1.b = r0;
        r0 = 1;
        goto L_0x01eb;
    L_0x01e4:
        r0 = new java.util.NoSuchElementException;
        r0.<init>();
        throw r0;
    L_0x01ea:
        r0 = 0;
    L_0x01eb:
        r6 = r1.d;
        monitor-enter(r6);
        r2 = r1.m;	 Catch:{ all -> 0x02c8 }
        if (r2 != 0) goto L_0x02c0;
    L_0x01f2:
        if (r0 == 0) goto L_0x0222;
    L_0x01f4:
        r0 = r1.b;	 Catch:{ all -> 0x02c8 }
        java.util.Objects.requireNonNull(r0);	 Catch:{ all -> 0x02c8 }
        r2 = new java.util.ArrayList;	 Catch:{ all -> 0x02c8 }
        r0 = r0.a;	 Catch:{ all -> 0x02c8 }
        r2.<init>(r0);	 Catch:{ all -> 0x02c8 }
        r0 = r2.size();	 Catch:{ all -> 0x02c8 }
        r9 = 0;
    L_0x0205:
        if (r9 >= r0) goto L_0x0222;
    L_0x0207:
        r10 = r2.get(r9);	 Catch:{ all -> 0x02c8 }
        r10 = (f.d0) r10;	 Catch:{ all -> 0x02c8 }
        r11 = f.f0.a.a;	 Catch:{ all -> 0x02c8 }
        r12 = r1.d;	 Catch:{ all -> 0x02c8 }
        r13 = r1.a;	 Catch:{ all -> 0x02c8 }
        r11.c(r12, r13, r1, r10);	 Catch:{ all -> 0x02c8 }
        r11 = r1.j;	 Catch:{ all -> 0x02c8 }
        if (r11 == 0) goto L_0x021f;
    L_0x021a:
        r1.c = r10;	 Catch:{ all -> 0x02c8 }
        r7 = 1;
        r8 = r11;
        goto L_0x0222;
    L_0x021f:
        r9 = r9 + 1;
        goto L_0x0205;
    L_0x0222:
        if (r7 != 0) goto L_0x0252;
    L_0x0224:
        if (r3 != 0) goto L_0x0244;
    L_0x0226:
        r0 = r1.b;	 Catch:{ all -> 0x02c8 }
        r2 = r0.a();	 Catch:{ all -> 0x02c8 }
        if (r2 == 0) goto L_0x023e;
    L_0x022e:
        r2 = r0.a;	 Catch:{ all -> 0x02c8 }
        r3 = r0.b;	 Catch:{ all -> 0x02c8 }
        r8 = r3 + 1;
        r0.b = r8;	 Catch:{ all -> 0x02c8 }
        r0 = r2.get(r3);	 Catch:{ all -> 0x02c8 }
        r3 = r0;
        r3 = (f.d0) r3;	 Catch:{ all -> 0x02c8 }
        goto L_0x0244;
    L_0x023e:
        r0 = new java.util.NoSuchElementException;	 Catch:{ all -> 0x02c8 }
        r0.<init>();	 Catch:{ all -> 0x02c8 }
        throw r0;	 Catch:{ all -> 0x02c8 }
    L_0x0244:
        r1.c = r3;	 Catch:{ all -> 0x02c8 }
        r1.i = r4;	 Catch:{ all -> 0x02c8 }
        r8 = new f.f0.f.c;	 Catch:{ all -> 0x02c8 }
        r0 = r1.d;	 Catch:{ all -> 0x02c8 }
        r8.m7707init(r0, r3);	 Catch:{ all -> 0x02c8 }
        r1.a(r8, r4);	 Catch:{ all -> 0x02c8 }
    L_0x0252:
        monitor-exit(r6);	 Catch:{ all -> 0x02c8 }
        if (r7 == 0) goto L_0x025b;
    L_0x0255:
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
        return r8;
    L_0x025b:
        r15 = r1.e;
        r0 = r1.f;
        r9 = r8;
        r10 = r18;
        r11 = r19;
        r12 = r20;
        r13 = r21;
        r14 = r22;
        r16 = r0;
        r9.c(r10, r11, r12, r13, r14, r15, r16);
        r0 = f.f0.a.a;
        r2 = r1.d;
        r0 = (f.v.a) r0;
        java.util.Objects.requireNonNull(r0);
        r0 = r2.e;
        r2 = r8.c;
        r0.a(r2);
        r2 = r1.d;
        monitor-enter(r2);
        r1.k = r5;	 Catch:{ all -> 0x02bd }
        r0 = f.f0.a.a;	 Catch:{ all -> 0x02bd }
        r3 = r1.d;	 Catch:{ all -> 0x02bd }
        r0 = (f.v.a) r0;	 Catch:{ all -> 0x02bd }
        java.util.Objects.requireNonNull(r0);	 Catch:{ all -> 0x02bd }
        r0 = r3.f;	 Catch:{ all -> 0x02bd }
        if (r0 != 0) goto L_0x029a;
    L_0x0291:
        r3.f = r5;	 Catch:{ all -> 0x02bd }
        r0 = f.g.g;	 Catch:{ all -> 0x02bd }
        r4 = r3.c;	 Catch:{ all -> 0x02bd }
        r0.execute(r4);	 Catch:{ all -> 0x02bd }
    L_0x029a:
        r0 = r3.d;	 Catch:{ all -> 0x02bd }
        r0.add(r8);	 Catch:{ all -> 0x02bd }
        r0 = r8.h();	 Catch:{ all -> 0x02bd }
        if (r0 == 0) goto L_0x02b2;
    L_0x02a5:
        r0 = f.f0.a.a;	 Catch:{ all -> 0x02bd }
        r3 = r1.d;	 Catch:{ all -> 0x02bd }
        r4 = r1.a;	 Catch:{ all -> 0x02bd }
        r0 = r0.b(r3, r4, r1);	 Catch:{ all -> 0x02bd }
        r8 = r1.j;	 Catch:{ all -> 0x02bd }
        goto L_0x02b3;
    L_0x02b2:
        r0 = 0;
    L_0x02b3:
        monitor-exit(r2);	 Catch:{ all -> 0x02bd }
        f.f0.c.g(r0);
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
        return r8;
    L_0x02bd:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x02bd }
        throw r0;
    L_0x02c0:
        r0 = new java.io.IOException;	 Catch:{ all -> 0x02c8 }
        r2 = "Canceled";
        r0.<init>(r2);	 Catch:{ all -> 0x02c8 }
        throw r0;	 Catch:{ all -> 0x02c8 }
    L_0x02c8:
        r0 = move-exception;
        monitor-exit(r6);	 Catch:{ all -> 0x02c8 }
        throw r0;
    L_0x02cb:
        r0 = new java.io.IOException;	 Catch:{ all -> 0x02e3 }
        r3 = "Canceled";
        r0.<init>(r3);	 Catch:{ all -> 0x02e3 }
        throw r0;	 Catch:{ all -> 0x02e3 }
    L_0x02d3:
        r0 = new java.lang.IllegalStateException;	 Catch:{ all -> 0x02e3 }
        r3 = "codec != null";
        r0.<init>(r3);	 Catch:{ all -> 0x02e3 }
        throw r0;	 Catch:{ all -> 0x02e3 }
    L_0x02db:
        r0 = new java.lang.IllegalStateException;	 Catch:{ all -> 0x02e3 }
        r3 = "released";
        r0.<init>(r3);	 Catch:{ all -> 0x02e3 }
        throw r0;	 Catch:{ all -> 0x02e3 }
    L_0x02e3:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x02e3 }
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.f.g.d(int, int, int, int, boolean):f.f0.f.c");
    }

    /* JADX WARNING: Removed duplicated region for block: B:47:0x0065 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0061 A:{LOOP_END, LOOP:0: B:0:0x0000->B:40:0x0061} */
    /* JADX WARNING: Missing block: B:8:0x000e, code skipped:
            r2 = 0;
     */
    /* JADX WARNING: Missing block: B:9:0x0015, code skipped:
            if (r0.e.isClosed() != false) goto L_0x005f;
     */
    /* JADX WARNING: Missing block: B:11:0x001d, code skipped:
            if (r0.e.isInputShutdown() != false) goto L_0x005f;
     */
    /* JADX WARNING: Missing block: B:13:0x0025, code skipped:
            if (r0.e.isOutputShutdown() == false) goto L_0x0028;
     */
    /* JADX WARNING: Missing block: B:14:0x0028, code skipped:
            r1 = r0.h;
     */
    /* JADX WARNING: Missing block: B:15:0x002b, code skipped:
            if (r1 == null) goto L_0x0036;
     */
    /* JADX WARNING: Missing block: B:16:0x002d, code skipped:
            monitor-enter(r1);
     */
    /* JADX WARNING: Missing block: B:18:?, code skipped:
            r2 = r1.g;
     */
    /* JADX WARNING: Missing block: B:19:0x0030, code skipped:
            monitor-exit(r1);
     */
    /* JADX WARNING: Missing block: B:20:0x0031, code skipped:
            r2 = r2 ^ 1;
     */
    /* JADX WARNING: Missing block: B:24:0x0036, code skipped:
            if (r12 == false) goto L_0x005e;
     */
    /* JADX WARNING: Missing block: B:26:?, code skipped:
            r1 = r0.e.getSoTimeout();
     */
    /* JADX WARNING: Missing block: B:28:?, code skipped:
            r0.e.setSoTimeout(1);
     */
    /* JADX WARNING: Missing block: B:29:0x0049, code skipped:
            if (r0.i.Q() == false) goto L_0x0051;
     */
    /* JADX WARNING: Missing block: B:31:?, code skipped:
            r0.e.setSoTimeout(r1);
     */
    /* JADX WARNING: Missing block: B:32:0x0051, code skipped:
            r0.e.setSoTimeout(r1);
     */
    /* JADX WARNING: Missing block: B:34:0x0058, code skipped:
            r0.e.setSoTimeout(r1);
     */
    public final f.f0.f.c e(int r7, int r8, int r9, int r10, boolean r11, boolean r12) throws java.io.IOException {
        /*
        r6 = this;
    L_0x0000:
        r0 = r6.d(r7, r8, r9, r10, r11);
        r1 = r6.d;
        monitor-enter(r1);
        r2 = r0.l;	 Catch:{ all -> 0x0066 }
        if (r2 != 0) goto L_0x000d;
    L_0x000b:
        monitor-exit(r1);	 Catch:{ all -> 0x0066 }
        return r0;
    L_0x000d:
        monitor-exit(r1);	 Catch:{ all -> 0x0066 }
        r1 = r0.e;
        r1 = r1.isClosed();
        r2 = 0;
        if (r1 != 0) goto L_0x005f;
    L_0x0017:
        r1 = r0.e;
        r1 = r1.isInputShutdown();
        if (r1 != 0) goto L_0x005f;
    L_0x001f:
        r1 = r0.e;
        r1 = r1.isOutputShutdown();
        if (r1 == 0) goto L_0x0028;
    L_0x0027:
        goto L_0x005f;
    L_0x0028:
        r1 = r0.h;
        r3 = 1;
        if (r1 == 0) goto L_0x0036;
    L_0x002d:
        monitor-enter(r1);
        r2 = r1.g;	 Catch:{ all -> 0x0033 }
        monitor-exit(r1);
        r2 = r2 ^ r3;
        goto L_0x005f;
    L_0x0033:
        r7 = move-exception;
        monitor-exit(r1);
        throw r7;
    L_0x0036:
        if (r12 == 0) goto L_0x005e;
    L_0x0038:
        r1 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r1 = r1.getSoTimeout();	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r4 = r0.e;	 Catch:{ all -> 0x0057 }
        r4.setSoTimeout(r3);	 Catch:{ all -> 0x0057 }
        r4 = r0.i;	 Catch:{ all -> 0x0057 }
        r4 = r4.Q();	 Catch:{ all -> 0x0057 }
        if (r4 == 0) goto L_0x0051;
    L_0x004b:
        r4 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r4.setSoTimeout(r1);	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        goto L_0x005f;
    L_0x0051:
        r4 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r4.setSoTimeout(r1);	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        goto L_0x005e;
    L_0x0057:
        r4 = move-exception;
        r5 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r5.setSoTimeout(r1);	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        throw r4;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
    L_0x005e:
        r2 = 1;
    L_0x005f:
        if (r2 != 0) goto L_0x0065;
    L_0x0061:
        r6.f();
        goto L_0x0000;
    L_0x0065:
        return r0;
    L_0x0066:
        r7 = move-exception;
        monitor-exit(r1);	 Catch:{ all -> 0x0066 }
        throw r7;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.f.g.e(int, int, int, int, boolean, boolean):f.f0.f.c");
    }

    public void f() {
        c cVar;
        Socket c;
        synchronized (this.d) {
            cVar = this.j;
            c = c(true, false, false);
            if (this.j != null) {
                cVar = null;
            }
        }
        f.f0.c.g(c);
        if (cVar != null) {
            Objects.requireNonNull(this.f);
        }
    }

    public void g() {
        c cVar;
        Socket c;
        synchronized (this.d) {
            cVar = this.j;
            c = c(false, true, false);
            if (this.j != null) {
                cVar = null;
            }
        }
        f.f0.c.g(c);
        if (cVar != null) {
            f.f0.a.a.d(this.e, null);
            Objects.requireNonNull(this.f);
            Objects.requireNonNull(this.f);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:30:0x0051  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x0051  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x0051  */
    public void h(java.io.IOException r7) {
        /*
        r6 = this;
        r0 = r6.d;
        monitor-enter(r0);
        r1 = r7 instanceof f.f0.i.u;	 Catch:{ all -> 0x0063 }
        r2 = 0;
        r3 = 0;
        r4 = 1;
        if (r1 == 0) goto L_0x0023;
    L_0x000a:
        r7 = (f.f0.i.u) r7;	 Catch:{ all -> 0x0063 }
        r7 = r7.a;	 Catch:{ all -> 0x0063 }
        r1 = f.f0.i.b.REFUSED_STREAM;	 Catch:{ all -> 0x0063 }
        if (r7 != r1) goto L_0x001c;
    L_0x0012:
        r7 = r6.i;	 Catch:{ all -> 0x0063 }
        r7 = r7 + r4;
        r6.i = r7;	 Catch:{ all -> 0x0063 }
        if (r7 <= r4) goto L_0x0046;
    L_0x0019:
        r6.c = r3;	 Catch:{ all -> 0x0063 }
        goto L_0x0044;
    L_0x001c:
        r1 = f.f0.i.b.CANCEL;	 Catch:{ all -> 0x0063 }
        if (r7 == r1) goto L_0x0046;
    L_0x0020:
        r6.c = r3;	 Catch:{ all -> 0x0063 }
        goto L_0x0044;
    L_0x0023:
        r1 = r6.j;	 Catch:{ all -> 0x0063 }
        if (r1 == 0) goto L_0x0046;
    L_0x0027:
        r1 = r1.h();	 Catch:{ all -> 0x0063 }
        if (r1 == 0) goto L_0x0031;
    L_0x002d:
        r1 = r7 instanceof f.f0.i.a;	 Catch:{ all -> 0x0063 }
        if (r1 == 0) goto L_0x0046;
    L_0x0031:
        r1 = r6.j;	 Catch:{ all -> 0x0063 }
        r1 = r1.l;	 Catch:{ all -> 0x0063 }
        if (r1 != 0) goto L_0x0044;
    L_0x0037:
        r1 = r6.c;	 Catch:{ all -> 0x0063 }
        if (r1 == 0) goto L_0x0042;
    L_0x003b:
        if (r7 == 0) goto L_0x0042;
    L_0x003d:
        r5 = r6.h;	 Catch:{ all -> 0x0063 }
        r5.a(r1, r7);	 Catch:{ all -> 0x0063 }
    L_0x0042:
        r6.c = r3;	 Catch:{ all -> 0x0063 }
    L_0x0044:
        r7 = 1;
        goto L_0x0047;
    L_0x0046:
        r7 = 0;
    L_0x0047:
        r1 = r6.j;	 Catch:{ all -> 0x0063 }
        r7 = r6.c(r7, r2, r4);	 Catch:{ all -> 0x0063 }
        r2 = r6.j;	 Catch:{ all -> 0x0063 }
        if (r2 != 0) goto L_0x0057;
    L_0x0051:
        r2 = r6.k;	 Catch:{ all -> 0x0063 }
        if (r2 != 0) goto L_0x0056;
    L_0x0055:
        goto L_0x0057;
    L_0x0056:
        r3 = r1;
    L_0x0057:
        monitor-exit(r0);	 Catch:{ all -> 0x0063 }
        f.f0.c.g(r7);
        if (r3 == 0) goto L_0x0062;
    L_0x005d:
        r7 = r6.f;
        java.util.Objects.requireNonNull(r7);
    L_0x0062:
        return;
    L_0x0063:
        r7 = move-exception;
        monitor-exit(r0);	 Catch:{ all -> 0x0063 }
        throw r7;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.f.g.h(java.io.IOException):void");
    }

    public void i(boolean z, c cVar, long j, IOException iOException) {
        c cVar2;
        Socket c;
        boolean z2;
        Objects.requireNonNull(this.f);
        synchronized (this.d) {
            if (cVar != null) {
                if (cVar == this.n) {
                    if (!z) {
                        cVar2 = this.j;
                        cVar2.l++;
                    }
                    cVar2 = this.j;
                    c = c(z, false, true);
                    if (this.j != null) {
                        cVar2 = null;
                    }
                    z2 = this.l;
                }
            }
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("expected ");
            stringBuilder.append(this.n);
            stringBuilder.append(" but was ");
            stringBuilder.append(cVar);
            throw new IllegalStateException(stringBuilder.toString());
        }
        f.f0.c.g(c);
        if (cVar2 != null) {
            Objects.requireNonNull(this.f);
        }
        if (iOException != null) {
            f.f0.a.a.d(this.e, iOException);
            Objects.requireNonNull(this.f);
        } else if (z2) {
            f.f0.a.a.d(this.e, null);
            Objects.requireNonNull(this.f);
        }
    }

    public String toString() {
        c b = b();
        return b != null ? b.toString() : this.a.toString();
    }
}
